package com.iraeta.entity.vo;

import com.iraeta.entity.gift.GiftType;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class GiftTypeTreeNode extends GiftType {
    public List<GiftType> children;

    public void addNode(GiftTypeTreeNode giftTypeTreeNode){
        if(children == null) this.children = new ArrayList<>();
        if(this.children.stream().anyMatch(x-> Objects.equals(x.getId(), giftTypeTreeNode.getId()))){
            return;
        }
        this.children.add(giftTypeTreeNode);
        giftTypeTreeNode.setPid(giftTypeTreeNode.getId());
    }
}
